using UnityEngine;
using System.Collections.Generic;

public class MovementToTarget : MonoBehaviour {
	public Transform target;
	public float velocity;
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update ()
	{
		Vector3 direction = target.position - this.transform.position;
		move(gameObject, direction,velocity);
	}
	
	/// <summary>
	/// Move the specified obj.
	/// </summary>
	/// <param name='obj'>
	/// The object that will be moved.
	/// </param>
	/// <param name='d'>
	/// A direction
	/// </param>
	/// <param name='v'>
	/// A velocity
	/// </param>
	public void move(GameObject obj,Vector3 d, float v)
	{
		obj.rigidbody.velocity = v * d.normalized;
	}
}
